package com.wanmait.recruit.filter;

import com.wanmait.recruit.util.PageContext;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter("/*")
public class PageFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        int pageNum = 1;
        try {
            pageNum = Integer.parseInt(request.getParameter("pageNum"));
        } catch (NumberFormatException e) {

        }
        PageContext.setPageNum(pageNum);
        try {
            chain.doFilter(request, response);
        } finally {
            PageContext.removePageNum();
        }

    }
}
